home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Apple Game Sprockets / InputSprocket 1.4 SDK / Interfaces&Libraries / InputSprocketDriver.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-04  |  9.1 KB  |  347 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        InputSprocketDriver.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                xxx put dri here xxx
  13.  
  14.         Other Contact:        xxx put other contact here xxx
  15.  
  16.         Technology:            xxx put technology here xxx
  17.  
  18.     Writers:
  19.  
  20.         (BWS)    Brent Schorsch
  21.  
  22.     Change History (most recent first):
  23.  
  24.         <24>     7/17/98    BWS        fix to Univ headers 3.0
  25. */
  26.  
  27. /*
  28.      File:        InputSprocketDriver.h
  29.  
  30.      Contains:    Driver interfaces for InputSprocket.
  31.                 Requires the software link with InputSprocketLib
  32.  
  33.      Version:    Technology:    InputSprocket 1.3
  34.                  Release:    InputSprocket 1.3
  35.  
  36.      Copyright:    © 1986-1998, 1995-1997 by Apple Computer, Inc., all rights reserved
  37.  
  38.      Bugs?:        Please include the the file and version information (from above) with
  39.                  the problem description.  Developers belonging to one of the Apple
  40.                  developer programs can submit bug reports to:
  41.  
  42.                      devsupport@apple.com
  43.  
  44. */
  45.  
  46. #ifndef __INPUTSPROCKETDRIVER__
  47. #define __INPUTSPROCKETDRIVER__
  48.  
  49.  
  50. #ifndef __MACTYPES__
  51. #include <MacTypes.h>
  52. #endif
  53. /*    #include <ConditionalMacros.h>                                */
  54.  
  55. #ifndef __ICONS__
  56. #include <Icons.h>
  57. #endif
  58.  
  59. #ifndef __DIALOGS__
  60. #include <Dialogs.h>
  61. #endif
  62.  
  63. #ifndef __INPUTSPROCKET__
  64. #include <InputSprocket.h>
  65. #endif
  66.  
  67. #if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
  68.     #pragma import on
  69. #endif
  70.  
  71. #ifdef __cplusplus
  72. extern "C" {
  73. #endif
  74.  
  75. #if PRAGMA_ALIGN_SUPPORTED
  76. #pragma options align=power
  77. #endif
  78.  
  79. /*
  80.  
  81. Resource File Concerns
  82.  
  83. 1. All resource ids of a driver should be in the range of 256 to 2048
  84. and the res file should only be open while the drivers panel is visable.
  85.  
  86. */
  87.  
  88. enum
  89. {
  90.     kOSType_ISpDriverFileType                = 'shlb',
  91.     kOSType_ISpDriverCreator                = 'insp'
  92. };
  93.  
  94. /*
  95.  *
  96.  * this function will plot an icon suite of the application (usually for a need)
  97.  *
  98.  */
  99.  
  100. OSErr ISpPlotAppIconSuite(const Rect *theRect,
  101.                     IconAlignmentType align, 
  102.                     IconTransformType transform, 
  103.                     short iconSuiteResourceId);
  104.  
  105. // label2,5,6,7, disabled and offline are reserved
  106.  
  107. enum
  108. {
  109.     kISpIconTransform_Selected                = kTransformSelected,
  110.     
  111.     // choose one of these (optionally) (these all erase what is behind them to the dialog color)
  112.     kISpIconTransform_PlotIcon                 = kTransformLabel1,
  113.     kISpIconTransform_PlotPopupButton         = kTransformLabel3,
  114.     kISpIconTransform_PlotButton             = kTransformLabel4,
  115.     
  116.     // use this is you want to plot the icon while the devices button is pressed
  117.     // or the devices axis is activated and so on
  118.     kISpIconTransform_DeviceActive            = kTransformOpen
  119. };
  120.  
  121. typedef UInt32 ISpMetaHandlerSelector;
  122. enum
  123. {
  124.     kISpSelector_Init =1,
  125.     kISpSelector_Stop,
  126.     kISpSelector_GetSize,
  127.     kISpSelector_HandleEvent,
  128.     kISpSelector_Show,
  129.     kISpSelector_Hide,
  130.     kISpSelector_BeginConfiguration,
  131.     kISpSelector_EndConfiguration,
  132.     kISpSelector_GetIcon,
  133.     kISpSelector_GetState,
  134.     kISpSelector_SetState,
  135.     kISpSelector_Dirty,
  136.     kISpSelector_SetActive,
  137.     kISpSelector_DialogItemHit,
  138.     kISpSelector_Tickle,            // 1.03 and later
  139.     kISpSelector_InterruptTickle,
  140.     kISpSelector_Draw,
  141.     kISpSelector_Click,
  142.     kISpSelector_ADBReInit            // 1.2 and later
  143. };
  144.  
  145.  
  146. /*
  147.  *
  148.  * typedefs for the function pointers the metahandler may return 
  149.  *
  150.  */
  151.  
  152. /* a generic driver function pointer */
  153. typedef OSStatus (* ISpDriverFunctionPtr_Generic)(UInt32 refCon, ...);
  154.  
  155. /* the meta handler pointer */
  156. typedef ISpDriverFunctionPtr_Generic (* ISpDriverFunctionPtr_MetaHandler)(UInt32 refCon, ISpMetaHandlerSelector);
  157.  
  158. /* the pointers you get through the meta handler */
  159. typedef OSStatus (* ISpDriverFunctionPtr_Init)(UInt32 refCon, UInt32 count, ISpNeed needs[], ISpElementReference virtualElements[], 
  160.                 Boolean used[], OSType appCreatorCode, OSType subCreatorCode, 
  161.                 UInt32 reserved, void* reserved2);
  162. typedef OSStatus (* ISpDriverFunctionPtr_Stop)(UInt32 refCon);
  163. typedef OSStatus (* ISpDriverFunctionPtr_GetSize)(UInt32 refCon, Point *minimum, Point *best);
  164. typedef OSStatus (* ISpDriverFunctionPtr_HandleEvent)(UInt32 refCon, EventRecord *theEvent, Boolean *handled);
  165. typedef OSStatus (* ISpDriverFunctionPtr_Show)(UInt32 refCon, DialogPtr theDialog, short dialogItemNumber, Rect *r);
  166. typedef OSStatus (* ISpDriverFunctionPtr_Hide)(UInt32 refCon);
  167. typedef OSStatus (* ISpDriverFunctionPtr_BeginConfiguration)(UInt32 refCon, UInt32 count, ISpNeed needs[]);
  168. typedef OSStatus (* ISpDriverFunctionPtr_EndConfiguration)(UInt32 refCon, Boolean accept);
  169. typedef OSStatus (* ISpDriverFunctionPtr_GetIcon)(UInt32 refCon, short *iconSuiteResourceId);
  170. typedef OSStatus (* ISpDriverFunctionPtr_GetState)(UInt32 refCon, UInt32 buflen, void *buffer, UInt32 *length);
  171. typedef OSStatus (* ISpDriverFunctionPtr_SetState)(UInt32 refCon, UInt32 length, void *buffer);
  172. typedef OSStatus (* ISpDriverFunctionPtr_Dirty)(UInt32 refCon, Boolean *dirty);
  173. typedef OSStatus (* ISpDriverFunctionPtr_SetActive)(UInt32 refCon, Boolean active);
  174. typedef OSStatus (* ISpDriverFunctionPtr_DialogItemHit)(UInt32 refCon, short itemHit);
  175.  
  176. // 1.03 and later
  177. typedef OSStatus (* ISpDriverFunctionPtr_Tickle)(UInt32 refCon);
  178. typedef OSStatus (* ISpDriverFunctionPtr_InterruptTickle)(UInt32 refCon);
  179. typedef OSStatus (* ISpDriverFunctionPtr_Draw)(UInt32 refCon);
  180. typedef OSStatus (* ISpDriverFunctionPtr_Click)(UInt32 refCon, const EventRecord *event);
  181.  
  182. // 1.2 and later
  183. typedef OSStatus (* ISpDriverFunctionPtr_ADBReInit)(UInt32 refCon, Boolean inPostProcess);
  184.  
  185. /* ********************* driver level functions ********************* */
  186.  
  187.  
  188. /*
  189.  *
  190.  * ISpDevice_New
  191.  *
  192.  * This creates a new device from the device definition structure and returns
  193.  * the result into the device reference.
  194.  *
  195.  * Returns Codes
  196.  * paramErr
  197.  * out of memory
  198.  * 
  199.  * Specical Considerations
  200.  * may not be done at interrupt time
  201.  */
  202.  
  203. OSStatus ISpDevice_New(    const ISpDeviceDefinition *inStruct, 
  204.                         ISpDriverFunctionPtr_MetaHandler metaHandler, 
  205.                         UInt32 refCon, 
  206.                         ISpDeviceReference *outReference);
  207.  
  208. /*
  209.  * ISpDevice_Dispose
  210.  *
  211.  * This disposes an existing device.
  212.  *
  213.  * Returns Codes
  214.  * paramErr
  215.  *
  216.  * Special Considerations
  217.  * May not be done at interrupt time
  218.  *
  219.  */
  220.  
  221. OSStatus ISpDevice_Dispose(ISpDeviceReference inReference);
  222.  
  223.  
  224. /*
  225.  *
  226.  * ISpElementDefinitionStruct
  227.  *
  228.  * This is the structure that defines everything static about this
  229.  * element.  For each element on your device you will need to 
  230.  * fill in one of these structures when your driver loads.
  231.  *
  232.  */
  233.  
  234. typedef struct ISpElementDefinitionStruct
  235. {
  236.     ISpDeviceReference device;  /* device this element belongs to */
  237.     UInt32 group;                /* group this element belongs to or 0 */
  238.     
  239.     Str63 theString;         /* a string that is a human readable identifier for this element, internationalization ? */
  240.         
  241.     ISpElementKind kind;        
  242.     ISpElementLabel label;        
  243.     
  244.     void *configInfo;         /* a pointer to the buffer containing the configuration information for this element */
  245.     UInt32 configInfoLength; /* length of that configuration info */
  246.  
  247.     UInt32 dataSize;         /* the size of the data, so we can generate an appropriate buffer */
  248.     
  249.     UInt32 reserved1;
  250.     UInt32 reserved2;
  251.     UInt32 reserved3;
  252. } ISpElementDefinitionStruct;
  253.  
  254. /*
  255.  *
  256.  * ISpElement_New
  257.  *
  258.  * ISpElement_New takes an element definition struct and gives you back a element reference.
  259.  * When you produce data you use that element reference to give the data to the system.
  260.  * 
  261.  * Return Codes
  262.  * paramErr
  263.  * memory error
  264.  *
  265.  * Special Considerations
  266.  * The ISpElement_New function may move or purge memory.  Your application should not call this function 
  267.  * at interrupt time.
  268.  * 
  269.  */
  270.  
  271. OSStatus ISpElement_New(const ISpElementDefinitionStruct *inStruct, ISpElementReference *outElement);
  272.  
  273. /*
  274.  *
  275.  * ISpElement_Dispose
  276.  *
  277.  * ISpElement_Dispose takes an element reference and deletes it.
  278.  * You should call this function when your driver unloads.
  279.  *
  280.  * Return Codes
  281.  * paramErr
  282.  * memory error
  283.  *
  284.  * Special Considerations
  285.  * The ISpElement_Dispose function may move or purge memory.  Your application should not call this function 
  286.  * at interrupt time.
  287.  * 
  288.  */
  289.  
  290. OSStatus ISpElement_Dispose(ISpElementReference inElement);
  291.  
  292. /*
  293.  *
  294.  * ISpElement_PushSimpleData
  295.  *
  296.  * ISpElement_PushSimpleData is the appropriate way to give the system data if your data fits exactly into
  297.  * a 32 bit signed number.  You pass the element reference that goes with the data, the data and the 
  298.  * AbsoluteTime that data was produced.  If UpTime is not available you should fill time.lo with the
  299.  * TickCount time and time.hi with 0.
  300.  *
  301.  * Return Codes
  302.  * paramErr
  303.  *
  304.  */
  305.  
  306. OSStatus ISpElement_PushSimpleData(ISpElementReference inElement, UInt32 data, const AbsoluteTime *time);
  307.  
  308. /*
  309.  *
  310.  * ISpElement_PushComplexData
  311.  *
  312.  * ISpElement_PushComplexData is exactly like ISpElement_PushSimpleData except that it is appropriate for times
  313.  * when your data does not fit into a signed 32 bit integer.
  314.  *
  315.  * Instead it takes the length of your data (which must match the datasize field of your ISpElementDefinitionStruct)
  316.  * and a ptr to the devices state.
  317.  *
  318.  * Return Codes
  319.  * paramErr
  320.  *
  321.  */
  322.  
  323. OSStatus ISpElement_PushComplexData(ISpElementReference inElement, UInt32 buflen, void *state, const AbsoluteTime *time);    
  324.  
  325.  
  326. /*
  327.  *
  328.  *
  329.  * use this to get the time
  330.  *
  331.  *
  332.  */
  333.  
  334. AbsoluteTime ISpUptime(void);
  335.  
  336. #ifdef __cplusplus
  337. }
  338. #endif
  339.  
  340.  
  341.  
  342. #if PRAGMA_ALIGN_SUPPORTED
  343. #pragma options align=reset
  344. #endif
  345.  
  346. #endif /* __INPUTSPROCKETDRIVER__ */
  347.